<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function greengar_get_location($user_id, $app) {
    $pairs = array();

    if ($app !== NULL) {
        $pairs[] = array('name' => LOCATION_ACC_CLIENT_ID, 'value' => $app, 'operand' => '=', 'case_sensitive' => FALSE);
    }
    if ($userid == ELGG_ENTITIES_ANY_VALUE) {
        $ownerids = ELGG_ENTITIES_ANY_VALUE;
    } else {
        $ownerids = array($userid);
    }
    $options = array(
        'types' => LOCATION_ACC_PARENT,
        'subtypes' => LOCATION_ACC_SUBTYPE,
        'metadata_names' => NULL,
        'metadata_values' => NULL,
        'metadata_name_value_pairs' => $pairs,
        'metadata_name_value_pairs_operator' => 'AND',
        'metadata_case_sensitive' => FALSE,
        'order_by_metadata' => array(),
        'metadata_owner_guids' => $ownerids,
        'limit' => 10000,
        'count' => FALSE
    );
    
    $entities = elgg_get_entities_from_metadata($options);
    return $entities;
}

?>
